package com.css.fxfzaqbz.modules.assess.controller;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.opengis.feature.simple.SimpleFeature;

import java.io.File;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) throws Exception {
//        File shapeFile = new File("C:\\Users\\罗燕师\\Desktop\\活断层数据\\测试断层.shp");
        File shapeFile = new File("C:\\Users\\Administrator\\Desktop\\sp\\chuqiguan.shp");
        ShapefileDataStore store = new ShapefileDataStore(shapeFile.toURI().toURL());
        //设置编码
        Charset charset = Charset.forName("UTF-8");
        store.setCharset(charset);
        SimpleFeatureSource sfSource = store.getFeatureSource();
        SimpleFeatureIterator sfIter = sfSource.getFeatures().features();
        // 从ShapeFile文件中遍历每一个Feature，然后将Feature转为GeoJSON字符串
        List<String> pointList=new ArrayList<>();
        while (sfIter.hasNext()) {
            SimpleFeature feature = sfIter.next();

        }
//        System.out.println(pointList);
    }
}
